<?php
/* 
 * ********* CVS HEADER ********* 
 * 
 * $RCSfile: adminscgroup.php,v $ 
 * $Date: 2005/10/21 12:58:07 $ 
 * $Revision: 1.3 $ 
 * 
 * ********* CVS HEADER ********* 
 */
if($confirm==1)
{
	$query="DELETE FROM groupe_inscription";
	$result=rportalrequete($query) or rportalerreur ($query,"?op=");
	$query="SELECT * FROM groupe ORDER BY id";
	$result=rportalrequete($query) or rportalerreur ($query,"?op=");
	while($row=rportalligne($result))
	{
		$arg = "argid".$row['id'];
		if($$arg==1)
		{
			$valeur = "alias".$row['id'];
			$a=$$valeur;
			$query="INSERT INTO groupe_inscription VALUES ('".$row['id']."','$a');";
			@rportalrequete($query) or rportalerreur ($query,"?op=");
		}
	}
	$rportalparams->set_key("RPORTAL","email.inscription.attente",$rauto,"int");
	$rportalparams->set_key("RPORTAL","email.inscription.accord",$oauto,"int");
	$rportalparams->set_key("RPORTAL","email.inscription.refus",$nauto,"int");
	$rportalparams->set_key("RPORTAL","email.inscription.alerte",$aauto,"int");
	
	header("Location: ?op=adminscgest");
	exit();
}
require_once('module/TPLN/TPLN.php');
$TPLN = new TPLN();
$TPLN->Open($op_basepath.'tpl/adminscgroup.html');
$TPLN->IncludeFile("header","environnement/$session[environnement]/header.php"); 
$TPLN->IncludeFile("footer","environnement/$session[environnement]/footer.php");

require_once(get_path_module("admin"));
$pc = new panneau_controle();
$pc->calculRubriqueParFonction($op);
$TPLN->Parse("panneau_controle",$pc->retourneEntete());

$query = "SELECT groupe.*,groupe_inscription.alias FROM groupe LEFT OUTER JOIN groupe_inscription";
$query.= " ON groupe.id=groupe_inscription.id_groupe";
$query.= " WHERE groupe.id!='".$rportalparams->get_value("RPORTAL","groupe.sequenceur")."'";
$query.= " AND groupe.id!='".$rportalparams->get_value("RPORTAL","groupe.corbeille")."'";
$query.= " AND groupe.id!='".$rportalparams->get_value("RPORTAL","groupe.archive")."'";
$query.= " ORDER BY groupe.id";

$result=rportalrequete($query) or rportalerreur($query,"?op=");
$class="liste_impaire";
while($row=rportalligne($result))
{
	if($row['alias']!=''){
		$TPLN->Parse("bloc1.ochecked","checked");
		$TPLN->Parse("bloc1.nchecked","");
	}else{
		$TPLN->Parse("bloc1.nchecked","checked");
		$TPLN->Parse("bloc1.ochecked","");
	}
	$TPLN->Parse("bloc1.nom",$row['nom']);
	$TPLN->Parse("bloc1.gid",$row['id']);
	$TPLN->Parse("bloc1.alias",$row['alias']);
	$TPLN->Parse("bloc1.classe",$class);
	if($class!="liste_impaire")
	{
		$class="liste_impaire";
	}else{
		$class="liste_paire";
	}
	$TPLN->Loop("bloc1");
}

$query="SELECT id,nom FROM rportal_email_type ORDER BY id";
$result=rportalrequete($query) or rportalerreur($query,"?op=");
while($row=rportalligne($result))
{
	$TPLN->Parse("rauto.eid",$row['id']);
	$TPLN->Parse("oauto.eid",$row['id']);
	$TPLN->Parse("nauto.eid",$row['id']);
	$TPLN->Parse("aauto.eid",$row['id']);
	$TPLN->Parse("rauto.enom",$row['nom']);
	$TPLN->Parse("oauto.enom",$row['nom']);
	$TPLN->Parse("nauto.enom",$row['nom']);
	$TPLN->Parse("aauto.enom",$row['nom']);
	if($rportalparams->get_value("RPORTAL","email.inscription.attente")==$row['id'])
		$TPLN->Parse("rauto.selected","selected");
	else
		$TPLN->Parse("rauto.selected","");
	if($rportalparams->get_value("RPORTAL","email.inscription.accord")==$row['id'])
		$TPLN->Parse("oauto.selected","selected");
	else
		$TPLN->Parse("oauto.selected","");
	if($rportalparams->get_value("RPORTAL","email.inscription.refus")==$row['id'])
		$TPLN->Parse("nauto.selected","selected");
	else
		$TPLN->Parse("nauto.selected","");
	if($rportalparams->get_value("RPORTAL","email.inscription.alerte")==$row['id'])
		$TPLN->Parse("aauto.selected","selected");
	else
		$TPLN->Parse("aauto.selected","");
	$TPLN->Loop("rauto");
	$TPLN->Loop("oauto");
	$TPLN->Loop("nauto");
	$TPLN->Loop("aauto");
}
$TPLN->Write();
?>